package com.xubeizhi.controller.system;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xubeizhi.annotation.OperationLogger;
import com.xubeizhi.common.ResponseResult;
import com.xubeizhi.entity.WebConfig;
import com.xubeizhi.service.WebConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 网站配置管理 前端控制器
 * @author mi
 * @create 2023/3/22 9:49
 */
@RestController
@RequestMapping("/system/webConfig")
@Api(tags = "网站配置管理")
@RequiredArgsConstructor
public class WebConfigController {

    private final WebConfigService webConfigService;


    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @SaCheckLogin
    @ApiOperation(value = "网站配置",httpMethod = "GET",response = ResponseResult.class,notes = "网站配置")
    public ResponseResult list(){
        return webConfigService.listWebConfig();
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @SaCheckPermission("/system/webConfig/update")
    @ApiOperation(value = "修改网站配置",httpMethod = "POST",response = ResponseResult.class,notes = "修改网站配置")
    @OperationLogger(value = "修改网站配置")
    public ResponseResult update(@RequestBody WebConfig webConfig){
        return webConfigService.updateWebConfig(webConfig);
    }
}
